package com.chocus.core.service.mq.listener;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;

import org.apache.activemq.command.ActiveMQTextMessage;
import org.springframework.beans.factory.annotation.Autowired;

import com.chocus.core.service.solr.SolrService;

/**
 * mq消息监听器处理类
 * 
 * @author Administrator
 *
 */
public class CustomerMessageListener implements MessageListener {

	@Autowired
	private SolrService solrService;

	@Override
	public void onMessage(Message message) {
		// TODO Auto-generated method stub
		ActiveMQTextMessage am = (ActiveMQTextMessage) message;
		try {
			System.out.println(am.getText());
			solrService.saveProductToSolr(Long.parseLong(am.getText()));
		} catch (JMSException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
